<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>即时消息</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	</head>

	<body>
	</body>
</html>
<script type="text/javascript">
    var newsArray=[];

    function showNews(){
        if(!newsArray||newsArray.length==0){
            loadUnreadNews2();
        }else{
            var news = newsArray.splice(newsArray.length-1,1)[0];
            var TITLE = news.TITLE||'';
            if(TITLE.length>10){
                TITLE = TITLE.substring(0,10)+" ...";
            }

            var CONTENT = news.CONTENT||'';
            if(CONTENT.length>50){
                CONTENT = CONTENT.substring(0,50)+" ...";
            }
            var FILE_INFO = news.FILE_INFO||'';
            var fileStr = "";
            if(FILE_INFO){
                fileStr = '<span  style="color:blue;font-weight:bold;">[附件]</span>';
            }
            $.messager.show({
                id:'news',
                title:'<div style="cursor:pointer" onclick="detailNews(\''+news.NEWS_ID+'\')" title='+news.TITLE+'>[公告]'+TITLE+'</div>',
                msg:'<div style="cursor:pointer" onclick="detailNews(\''+news.NEWS_ID+'\')">' +
                        '<span style="font-weight:bold;font-size:14px" >'+CONTENT+'</span>' +fileStr+
                        '</br></br>'+
                        '<span  style="font-weight:bold;float:right" >'+(news.NAME||'')+'</span></br>'+
                        '<span  style="font-weight:bold;float:right" >'+(news.PUBLISH_TIME||'')+'</span></div>' ,
                timeout:60000,
                showType:'slide',
                height:220,
                width:250,
                modal:true,
                openShow:function(){
                    $.ajax({//标记已提示
                        url: 'recordPopNews.do',
                        type: "POST",
                        data: {id:news.NEWS_ID},
                        cache: false,
                        error:function(){
                            alert('连接服务器失败，请重新登录！');
                        },
                        success: function(msg){

                        }
                    });
                },
                closeShow:function(){
                    showNews();
                }
            }).window("window").css("right","10px");
        }

    }
    function loadUnreadNews2(){
        $.ajax({
            url: 'loadUnreadNews.do',
            type: "POST",
            data: {},
            cache: false,
            error:function(){
                alert('连接服务器失败，请重新登录！');
            },
            success: function(msg){
                if(!msg||msg.length==0){
                    return false;
                }
                $.each(msg||[],function(k,v){
                    newsArray.push(v);
                })
                showNews();
            }
        });

    }
    function detailNews(id){
        window.showModalDialog("loadAddNews.do?id="+id+"&op=view&nowtime="+new Date(), "", "dialogWidth=800px,dialogHeight=600px");
    }


</script>
